﻿CREATE FUNCTION SumTo(
	@Start int
)RETURNS int WITH SCHEMABINDING AS BEGIN

DECLARE @Res int SET @Res = 0

WHILE @Start > 0 
	SELECT @Res = @Res + @Start, @Start = @Start -1 

RETURN @Res
END